package noahzu.github.io.baselib.base;

import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.umeng.analytics.MobclickAgent;


import cn.bmob.v3.Bmob;

/**
 * Created by zujinhao on 17/6/5.
 */

public abstract class BaseFragment extends Fragment {
    protected View rootView = null;



    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (rootView == null){
            rootView = inflater.inflate(getLayout(),container,false);
            Bmob.initialize(getContext(),"65491c4369cf251da7743364bc4b3c6b");
            findView();
            initData();
            initView();
        }
        return rootView;
    }

    protected abstract int getLayout();

    protected abstract void findView();

    protected abstract void initData();

    protected abstract void initView();


    protected View findViewById(@IdRes int id){
        return rootView.findViewById(id);
    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(getContext());
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(getContext());

    }

}
